package LeetCode.month02.day55;

import java.util.ArrayList;
import java.util.List;

public class No530 {
    List<Integer> list = new ArrayList<>();
    public int getMinimumDifference(TreeNode root) {
        dfs(root);
        int res = Integer.MAX_VALUE;
        for (int i = 1; i < list.size(); i++) {
            res = Math.min(list.get(i)-list.get(i-1),res);
        }
        return res;
    }

    public void dfs(TreeNode root){
        if(root==null) return;
        dfs(root.left);
        list.add(root.val);
        dfs(root.right);
    }
}
